package com.trainer.Attributes;

import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.Formatter;

public class Duration extends ExAttribute{
	long mTime; //in milliseconds
	
	public Duration(long time)
	{
		mTime = time;
	}
	
	public Duration(int hours, int minutes, int seconds)
	{
		mTime = (hours*60*60*1000) + (minutes*60*1000) + (seconds*1000);
	}
	
	public long GetTimeInMilli()
	{
		return mTime;
	}
	
	public double GetTimeInSec()
	{
		return mTime/1000.0;
	}
	
	public double GetTimeInMin()
	{
		return (mTime/1000.0)/60.0;
	}
	
	public double GetTimeInHour()
	{
		return (mTime/1000.0)/60.0/60.0;
	}
	
	public int GetSeconds()
	{
		return (int)Math.floor(mTime/1000.0);
	}
	
	public int GetMinutes()
	{
		return (int)Math.floor(mTime/1000.0/60.0);
	}
	
	public int GetHours()
	{
		return (int)Math.floor(mTime/1000.0/60.0/60.0);
	}
	
	public String GetTimeString()
	{
		NumberFormat format = new DecimalFormat("##00");
		
		return GetHours()
		+ ":" + format.format(GetMinutes()%60)
		+ ":" + format.format(GetSeconds()%60);
	}
	
	public String Display()
	{
		return "Duration: " + GetTimeString();
	}
}
